The present invention relates to computer graphics, and more particularly to texture sampling in a computer graphics processing pipeline.
Recent advances in computer performance have enabled graphic systems to provide more realistic graphical images using personal computers and home video game computers. In such graphic systems, some procedure must be implemented to xe2x80x9crenderxe2x80x9d or draw graphic primitives to the screen of the system. A xe2x80x9cgraphic primitivexe2x80x9d is a basic component of a graphic picture, such as a polygon, e.g., a triangle, or a vector. All graphic pictures are formed with combinations of these graphic primitives. Many procedures may be utilized to perform graphic primitive rendering.
Early graphic systems displayed images representing objects having extremely smooth surfaces. That is, textures, bumps, scratches, or other surface features were not modeled. In order to improve the quality of the image, texture mapping was developed to model the complexity of real world surface images. In general, texture mapping is the mapping of an image or a function onto a surface in three dimensions. Texture mapping is a relatively efficient technique for creating the appearance of a complex image without the tedium and the high computational cost of rendering the actual three dimensional detail that might be found on a surface of an object.
Prior Art FIG. 1 illustrates a graphics pipeline with which texture mapping may be performed. As shown, included is a transform engine 100, a set-up module 102, a rasterizer 104, a texture math module 106, a level of detail (LOD) calculator 108, a texture fetch module 110, a texture filter 112, and a texture combination engine 114. It should be noted that the transform engine 100 and set-up module 102 need not necessarily be required in the graphics pipeline of a graphics integrated circuit.
During operation, the transform engine 100 may be used to perform scaling, rotation, and projection of a set of three dimensional vertices from their local or model coordinates to the two dimensional window that will be used to display the rendered object. The setup module 102 utilizes the world space coordinates provided for each triangle to determine the two dimensional coordinates at which those vertices are to appear on the two dimensional window. Prior Art FIG. 2 illustrates the coordinates 200 of the vertices 201 which define a triangle 202. If the vertices 201 of the triangle 202 are known in screen space, the pixel positions vary along scan lines within the triangle 202 in screen space and may be determined.
The setup module 102 and the rasterizer module 104 together use the three dimensional world coordinates to determine the position of each pixel contained inside each of the triangles. Prior Art FIG. 3 illustrates a plurality of pixels 300 identified within the triangle 202 in such a manner. The color values of the pixels in the triangle 202 vary from pixel to pixel in world space. During use, the setup module 102 and the rasterizer module 104 generate interpolated colors, depth and texture coordinates.
The setup module 102 and the rasterizer module 104 then feed the pixel texture coordinates to the texture math module 106 to determine the appropriate texture map colors. In particular, texture coordinates are generated that reference a texture map using texture coordinate interpolation which is commonly known to those of ordinary skill in the art. This is done for each of the pixels 300 identified in the triangle 202. Prior Art FIG. 3 illustrates texture coordinates 302 for the pixels 300 identified within the triangle 202.
Next, a LOD calculation is performed by the LOD calculator 108. Occasionally during rendering, one texel, or texture element, will correspond directly to a single pixel that is displayed on a monitor. In this situation the level of detail (LOD) is defined to be equal to zero (0) and the texel is neither magnified nor minified. However, the displayed image can be a magnified or minified representation of the texture map. If the texture map is magnified, multiple pixels will represent a single texel. A magnified texture map corresponds to a negative LOD value. If the texture map is minified, a single pixel represents multiple texels. A minified texture map corresponds to a positive LOD value. In general, the LOD value corresponds to the number of texels in the texture map xe2x80x98coveredxe2x80x99 by a single pixel.
The amount of detail stored in different LOD representations may be appreciated by drawing an analogy to the detail perceived by an observer while observing a texture map. For example, very little detail may be perceived by an observer while watching an automobile from a distance. On the other hand, several details such as doors, windows, mirrors will be perceived if the observer is sufficiently close to the automobile. A finer level LOD will include such additional details, and a courser LOD will not.
Once the appropriate level of detail of the texture map is selected based on the calculated LOD value, the texture coordinates generated by the texture math module 106 are used to fetch the appropriate texture map colors using the texture fetch module 110. These texture map colors are then filtered by the texture filter module 112. The combiner engine 114 combines together the various colors and textures fetched by the texture fetch module 110 and filtered by the texture filter module 112.
It is important to note that the pipeline described hereinabove has a linear topology. These and other simplistic non-linear pipelines only enable one texture fetch and texture calculation per rendering pass. This is a limited design that is static in nature. There is thus a need for a pipeline that allows for more dynamic texture fetches and shading calculations, and in particular, the ability for feeding filter results back to influence subsequent texture address calculations.
By implementing such a modified pipeline, floating point conversions may be required while performing shading calculations. While well-known, simple techniques exist for converting integers into the standard IEEE floating point representations, such are limited and only very useful if the number being used for the floating point divisor is a power of 2 (like 256, 128, 65536, 32768) or one off from a power of 2 (like 255, 127, 65535). There is thus a need for an optimized technique of converting color data into floating point values in a graphics pipeline.
A system, method and article of manufacture are provided for converting color data into floating point values in a graphics pipeline. First, color data is received. Next, the color data is separated into a plurality of components each including an integer. The components of color data are then converted into floating point values by dividing at least a portion of the components by predetermined numbers.
In one embodiment, the color data is thirty-two (32) bits in length. Further, the floating point values, i.e. (d,e,f), may be used to combine the color data with a set of coordinates (r,g,b) using a dot product.
In one set of embodiments of the present invention, the components include four (4) components (A, R, G, B) each eight (8) bits in length. In a first embodiment of the first set, the components (A, R, G, B) are unsigned integers on [0,255], and the components of color data are converted into the floating point values (d,e,f) using the following equations: d=R/255.0, e=G/255.0, and f=B/255.0, such that the floating point values (d,e,f) are on [0,1].
In a second embodiment of the first set, the components (A, R, G, B) are signed integers on [xe2x88x92128,127], and the components of color data are converted into the floating point values (d,e,f) using the following equations d=R/128.0, e=G/128.0, and f=B/128.0, such that the floating point values (d,e,f) are on [xe2x88x921,1).
In a third embodiment of the first set, the components (A, R, G, B) are signed integers on [xe2x88x92128,127], and the components of color data are converted into the floating point values (d,e,f) using the following equations d=R/127.0, e=G/127.0, and f=B/127.0, such that the floating point values (d,e,f) are on [xe2x88x92128/127, 1.0].
In a fourth embodiment of the first set, the components (A, R, G, B) are signed integers on [xe2x88x92128,127], and the components of color data are converted into the floating point values (d,e,f) using the following equations d=(R+0.5)/127.5, e=(G+0.5)/127.5, and f=(B+0.5)/127.5, such that the floating point values (d,e,f) are on [xe2x88x921, 1].
In a second set of embodiments of the present invention, the components include two (2) components (H, L) each sixteen (16) bits in length. In a first embodiment of the second set, the components (H, L) are unsigned integers on [0,65535], and the components of color data are converted into the floating point values (d,e,f) using the following equations d=H/65535.0, e=L/65535.0, and f=1.0, such that the floating point values (d,e,f) are on [0.0, 1.0].
In a second embodiment of the second set, the components (H, L) are signed integers on [xe2x88x9232768, 32767], and the components of color data are converted into the floating point values (d,e,f) using the following equations d=H/132768.0, e=L/32768.0, and f=square root(1.0xe2x88x92H*Hxe2x88x92L*L).
These and other advantages of the present invention will become apparent upon reading the following detailed description and studying the various figures of the drawings.